﻿import QtQuick 2.7
import QtQuick.Window 2.2
import QtQuick.Controls 2.0
import QtMultimedia 5.0
import "QuestionBox"


import com.leamus.gamedata 1.0

import "Poke"
import "Player"
import "Process"
import "Button"
import "global.js" as GlobalConst
import "functions.js" as Functions

//import "Poke/Temp.js" as PokeClass
//import "gameCore.js" as GameCore


Window {

    //property alias msgBox: msgBox
    property var pokeArray: new Array
    property var playerArray: new Array
    property var wuJiangArray: new Array

    property int playerCount: 0
    property int playerMaxCount: 0
    property int pokeMaxCount: 0
    property int myID: -1

    //界面size
    property real pixelDensity: 4.46
    property real multiplierH: height/600 //default multiplier, but can be changed by user
    property real multiplierW: width/1024 //default multiplier, but can be changed by user
    function dpH(numbers) {
        return numbers * gameWindow.height / GlobalConst.GAMEWINDOW_HEIGHT
        //return Math.round(numbers*((pixelDensity*25.4)/160)*multiplierH);
    }
    function dpW(numbers) {
        return numbers * gameWindow.width / GlobalConst.GAMEWINDOW_WIDTH
        //return Math.round(numbers*((pixelDensity*25.4)/160)*multiplierW);
    }

    signal buttonClicked(int type)


    id: gameWindow
    objectName: "windowObject"
    visible: false
    width: GlobalConst.GAMEWINDOW_WIDTH
    height: GlobalConst.GAMEWINDOW_HEIGHT
    title: qsTr("英语杀")


    Image {
        anchors.fill: parent
        fillMode: Image.PreserveAspectCrop
        z: 0.01
        source: "../Images/System/bd.bmp"
        anchors {
            //fill: parent
        }
    }

    Image {
        x: dpW(0)
        y: dpH(450)
        z: 0.02
        width: dpW(sourceSize.width)
        height: dpH(sourceSize.height)
        source: "../Images/System/dashboard-hand.png"
        anchors {
            //fill: parent
        }
    }

    Image {
        x: dpW(0)
        y: dpH(450)
        z: 0.04
        width: dpW(sourceSize.width)
        height: dpH(sourceSize.height)
        source: "../Images/System/dashboard-equip.png"
        anchors {
            //fill: parent
        }
    }

    Image {
        x: dpW(850)
        y: dpH(450)
        z: 0.03
        width: dpW(sourceSize.width)
        height: dpH(sourceSize.height)
        source: "../Images/System/dashboard-avatar.png"
        anchors {
            //fill: parent
        }
    }

    Image {
        x: dpW(750)
        y: dpH(450)
        z: 0.04
        width: dpW(sourceSize.width)
        height: dpH(sourceSize.height)
        source: "../Images/System/platter/bg.png"
        anchors {
            //fill: parent
        }

        ImageButton {
            id: buttonOK
            x: dpW(4)
            y: dpH(5)
            z: 0.2
            width: dpW(sourceSize.width)
            height: dpH(sourceSize.height)
            onBuntonClicked: {
                //console.debug(GameCore.Game_Button_OK);
                buttonClicked(GameClass.Game_Button_OK)
            }
            Component.onCompleted: {
                addImage("Image/OK/normal.png",0)
                addImage("Image/OK/hover.png",1)
                addImage("Image/OK/down.png",2)
                addImage("Image/OK/disabled.png",3)
            }
        }

        ImageButton {
            id: buttonCancel
            x: dpW(4)
            y: dpH(93)
            z: 0.2
            width: dpW(sourceSize.width)
            height: dpH(sourceSize.height)
            onBuntonClicked: {
                //console.debug(GameCore.Game_Button_Cancel);
                buttonClicked(GameClass.Game_Button_Cancel)
            }
            Component.onCompleted: {
                addImage("Image/Cancel/normal.png",0)
                addImage("Image/Cancel/hover.png",1)
                addImage("Image/Cancel/down.png",2)
                addImage("Image/Cancel/disabled.png",3)
            }
        }
        ImageButton {
            id: buttonGiveup
            x: dpW(70)
            y: dpH(39)
            z: 0.2
            width: dpW(sourceSize.width)
            height: dpH(sourceSize.height)
            onBuntonClicked: {
                //console.debug(PokeClass.Type_Button,PokeClass.Flag_Clicked);
                //console.debug(GameCore.Game_Button_Giveup);
                buttonClicked(GameClass.Game_Button_Giveup)

            }
            Component.onCompleted: {
                addImage("Image/Giveup/normal.png",0)
                addImage("Image/Giveup/hover.png",1)
                addImage("Image/Giveup/down.png",2)
                addImage("Image/Giveup/disabled.png",3)
            }
        }

    }

    MsgBox {
        id: msgBox
        textArea.readOnly: true
        x: dpW(GlobalConst.msgBoxRect[0])
        y: dpH(GlobalConst.msgBoxRect[1])
        z: 0.1
        width: dpW(GlobalConst.msgBoxRect[2])
        height: dpH(GlobalConst.msgBoxRect[3])
        //enabled: false

        //z: 3

        Component.onCompleted: {
            //appendText().connect
        }
    }

    MsgBox {
        id: debugMsg
        x: dpW(GlobalConst.msgBoxRect[0])
        y: dpH(GlobalConst.msgBoxRect[1] + msgBox.height + 10)
        z: 0.1
        width: dpW(GlobalConst.msgBoxRect[2])
        height: dpH(80)
        //enabled: false

        //z: 3

        Component.onCompleted: {
            //appendText().connect
        }
    }

    Text {
        id: shortMsg
        x: dpW(GlobalConst.ShortMessage_Pos[0])
        y: dpH(GlobalConst.ShortMessage_Pos[1])
        z: 0.2
        width: dpW(200)
        text: "准备开始...";
        font.pixelSize: 24;
        style: Text.Outline;
        styleColor: "white"
        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignVCenter
    }

    Progress {
        x: dpW(GlobalConst.Progress_Pos[0])
        y: dpH(GlobalConst.Progress_Pos[1])
        z: 0.3
        width: dpW(100)
        height: dpH(10)
        id: progress
        onTimeUp: {
            buttonClicked(-1)
        }
    }

    Canvas {
        id: canvas
        z: 200
        visible: true
        anchors.fill: parent
        //contextType: "2d"
        property var lineList : []
        onPaint: {
            var ctx = getContext("2d");
            ctx.lineWidth = 2
            ctx.lineJoin = "round"
            ctx.strokeStyle="yellow"
            //ctx.beginPath()

            //ctx.fillStyle = Qt.rgba(0,0,0,50)
            //ctx.fillRect(0,0,160,160);

            ctx.clearRect(0, 0, width, height)
            ctx.beginPath()

            //ctx.moveTo(0,0)
            //ctx.lineTo(100,100)
            //console.debug("lineListCount:",lineList.length)

            var i = 0, j;
            var x1,y1,x2,y2
            while(i < lineList.length) {
                x1 = playerArray[lineList[i]].x + playerArray[lineList[i]].width / 2
                y1 = playerArray[lineList[i]].y + playerArray[lineList[i]].height / 2
                ctx.moveTo(x1, y1)
                if(lineList[i+1] == -1) {
                    for(j = 0; j < gameWindow.playerCount; j++) {
                        if(lineList[i] != j && playerArray[j].bDead == false) {
                            x2 = playerArray[j].x + playerArray[j].width / 2;
                            y2 = playerArray[j].y + playerArray[j].height / 2;
                            ctx.moveTo(x1,y1)
                            ctx.lineTo(x2,y2)
                        }
                    }
                }
                else {
                    x2 = playerArray[lineList[i+1]].x + playerArray[lineList[i+1]].width / 2;
                    y2 = playerArray[lineList[i+1]].y + playerArray[lineList[i+1]].height / 2;
                    ctx.lineTo(x2,y2)
                    //console.debug("canvas:",x1,y1,i,x2,y2)
                }

                //console.debug("lineList::",lineList[i],lineList[i+1])
                i++
                i++

            }

            ctx.closePath()
            ctx.stroke()


            //ctx.fillRect(150,50,300,600)
            //ctx.clearRect(100,100,200,500)
        }
        Timer {
            id: canvasHideTimer
            interval: 1000
            repeat: false
            onTriggered: {
                canvas.visible = false;
                //convas.visible = true;
                //convas.paint(convas.canvasSized)
                //convas.requestPaint()
                //convas.markDirty(Qt.rect(convas.x,convas.y,convas.width,convas.height))
                //convas.markDirty(Qt.rect(0,0,500,500))
                //convas.paint(Qt.rect(convas.x,convas.y,convas.width,convas.height))

            }
        }
    }

    QuestionBox {
        id: questionBox
        x: dpW(300); y:dpH(200)
        z: 300
        //color: Qt.rgba(0.5,0.5,0.5,0.9)
        //color: "#700090FF"
        color: "#A0FFFFFF"
        visible: false
        showMask: true
        animationType: "fade";
        easingType: Easing.Linear
        duration: 200

        maskColor: "black"
        maskOpacity: 0.5
    }

    Audio {
            id : _audio
            source: "backMusic.mp3"
            loops: Audio.Infinite
    }

    Button {
        id: debug1
        x: 550; y:650; z:0.3
        text: "牌堆"
        onClicked: buttonClicked(10)
    }
    Button {
        id: debug2
        x: 670; y:650; z:0.3
        text: "弃牌堆"
        onClicked: buttonClicked(11)
    }

    Button {
        id: debug3;
        x: 790; y:650; z:0.3
        text: "0手牌"
        onClicked: buttonClicked(12)
    }
    Button {
        id: debug4
        x: 910; y:650; z:0.3
        text: "1手牌"
        onClicked: buttonClicked(13)
    }

    /*
    ImageButton {
        id: buttonOK2
        x: 100
        y: 100
        z: 0.2
        onBuntonClicked: {
            //console.debug(GameCore.Game_Button_OK);
            buttonClicked(10)
        }
        Component.onCompleted: {
            addImage("Image/OK/normal.png",0)
            addImage("Image/OK/hover.png",1)
            addImage("Image/OK/down.png",2)
            addImage("Image/OK/disabled.png",3)
        }
    }

    ImageButton {
        id: buttonOK3
        x: 200
        y: 100
        z: 0.2
        onBuntonClicked: {
            //console.debug(GameCore.Game_Button_OK);
            buttonClicked(11)
        }
        Component.onCompleted: {
            addImage("Image/OK/normal.png",0)
            addImage("Image/OK/hover.png",1)
            addImage("Image/OK/down.png",2)
            addImage("Image/OK/disabled.png",3)
        }
    }
    */


    Component {
        id: pokeComp
        Poke {
            property bool bIsMine: false
        }
    }
    Component {
        id: playerComp
        Player {
        }
    }

    function _W(w) {
        return w;
    }

    function _H(h) {
        return h;
    }



    function setPokeFlags(i,flags) {
        //console.debug("PokeFlags:",pokeArray[0].id)
        //console.debug("setPokeFlags:",i,flags)
        pokeArray[i].flags = flags;
        if(GameCore.pokeList[i].positionArea == PokeClass.Area_ShouPai
                && GameCore.pokeList[i].positionPlayer == myID) {
            if(flags & PokeClass.Flag_Clicked)
                pokeArray[i].aniMoveTo(pokeArray[i].aniDx, GlobalConst.ShouPai_Pos[1] - GlobalConst.ShouDPai_Y);
            else
                pokeArray[i].aniMoveTo(pokeArray[i].aniDx, GlobalConst.ShouPai_Pos[1]);
        }

    }

    function setPokePosition(i,area,value,player) {
        switch(area) {
        case PokeClass.Area_ShouPai:
            if(player == myID) {    //玩家本人,则显示手牌
                pokeArray[i].bZhengMian = true;
                pokeArray[i].bIsMine = true
                //pokeArray[i].visible = true
                pokeArray[i].opacity = 1;
                pokeArray[i].z = GlobalConst.Z_ShouPai + value / 100
                pokeArray[i].aniMoveTo(GlobalConst.ShouPai_Pos[0] + GlobalConst.ShouPai_DX * value,GlobalConst.ShouPai_Pos[1])


                //对比dx,如果不同则重新排列
                var dx = GlobalConst.paiQuWidth / GameCore.playerList[myID].shouPaiList.length;
                if(dx > GlobalConst.paiWidth)dx = GlobalConst.paiWidth;
                if(dx != GlobalConst.ShouPai_DX) {  //上次dx和这次dx不同
                    GlobalConst.ShouPai_DX = dx;
                    //console.debug("chongxinpailie:",GlobalConst.ShouPai_DX,dx,GameCore.playerList[myID].shouPaiList.length)
                    //var j = 0;

                    for(i = 0; i < GameCore.playerList[myID].shouPaiList.length; i++) {
                        //console.debug("move:",i,GameCore.playerList[myID].shouPaiList[i].id,GlobalConst.ShouPai_Pos[0] + dx * GameCore.playerList[myID].shouPaiList[i].positionValue)
                        pokeArray[GameCore.playerList[myID].shouPaiList[i].id].aniMoveTo(GlobalConst.ShouPai_Pos[0] + dx * GameCore.playerList[myID].shouPaiList[i].positionValue,GlobalConst.ShouPai_Pos[1])
                    }
                    /*
                    for(var pai in GameCore.playerList[myID].shouPaiList) {
                        console.debug(pai)
                        setPokePos(pai,GlobalConst.ShouPai_Pos[0] + 50 * value,GlobalConst.ShouPai_Pos[1])
                        console.debug(pai)
                    }*/
                }

                //console.debug(i,pokeArray[i].x,pokeArray[i].y,pokeArray[i].z,pokeArray[i].visible)
            }
            else {
                //console.debug("id::::",player,myID)
                pokeArray[i].bZhengMian = false;
                pokeArray[i].bIsMine = false
                pokeArray[i].aniMoveTo(playerArray[player].x, playerArray[player].y)
                pokeArray[i].aniOpacity(0);
                //pokeArray[i].visible = false
            }
            break;
        case PokeClass.Area_ZhuangBei:
            pokeArray[i].bZhengMian = true;
            pokeArray[i].bIsMine = false
            pokeArray[i].opacity = 1;
            //pokeArray[i].visible = true
            pokeArray[i].z = GlobalConst.Z_ShouPai + value/100
            pokeArray[i].aniMoveTo(playerArray[player].x - 100,playerArray[player].y)
            break;
        case PokeClass.Area_PanDing:
            pokeArray[i].bZhengMian = true;
            pokeArray[i].bIsMine = false
            pokeArray[i].opacity = 1;
            //pokeArray[i].visible = true
            pokeArray[i].z = GlobalConst.Z_ShouPai + value/100
            pokeArray[i].aniMoveTo(playerArray[player].x + 80, playerArray[player].y - 10)
            //pokeArray[i].aniOpacity(0);
            break;
        case PokeClass.Area_PaiDui:
            pokeArray[i].bZhengMian = false;
            pokeArray[i].bIsMine = false
            pokeArray[i].opacity = 1;
            pokeArray[i].moveTo(GlobalConst.PAIDUI_X,GlobalConst.PAIDUI_Y);
            //pokeArray[i].visible = false
            break;
        case PokeClass.Area_QiPaiDui:
            //if(pokeArray[i].bIsMine && pokeArray[i].visible)    //如果从本玩家移出
            pokeArray[i].bZhengMian = true;
            pokeArray[i].opacity = 1;
            pokeArray[i].aniMoveTo(GlobalConst.QIPAIDUI_X,GlobalConst.QIPAIDUI_Y);
            pokeArray[i].bIsMine = false
            pokeArray[i].aniOpacity(0);
            //pokeArray[i].visible = false
            break;
        }
    }
/*
    function setPokePos(i,dx,dy) {
        pokeArray[i].x = dx;
        pokeArray[i].y = dy;
        //pokeArray[i].aniMoveTo(dx,dy)
    }*/



    function setPlayerFlags(i,flags) {
        //console.debug("setplayerFlag:",i,flags)
        playerArray[i].flags = flags;
    }

    function setPlayerPos(i,x,y) {
        playerArray[i].x = x;
        playerArray[i].y = y;
    }
/*
    function setPlayerPixmap(i,pixmapSrc) {
        playerArray[i].source = pixmapSrc;
    }
*/
    function setPlayerBlood(i,blood,maxBlood) {
        //console.debug("setPlayerBlood",i,blood,maxBlood)
        playerArray[i].setBlood(blood,maxBlood);
    }


    //游戏总初始化
    function initialization(iPokeMaxCount,iPlayerMaxCount) {
        //console.debug(iPokeMaxCount,iPlayerMaxCount)
        pokeMaxCount = iPokeMaxCount
        playerMaxCount = iPlayerMaxCount
        var i;
        //console.debug(GameCore.strlist.length)
        //牌
        for(i = 0; i < GameCore.pokeList.length; i++) {
            pokeArray[i] = pokeComp.createObject(gameWindow,{"flags": PokeClass.Flag_Null, "width": dpW(GlobalConst.paiWidth), "height": dpH(GlobalConst.paiHeight)});
            pokeArray[i].userData = i;

            pokeArray[i].debugMessage.connect(function(str){debugMsg.appendText(str);})
            //console.debug(typeof(GameCore.pokeList),GameCore.pokeList)
            //console.debug(i)
            //console.debug(typeof(GameCore.pokeList[0]),GameCore.pokeList[0])
            //console.debug(typeof(GameCore.pokeList[0].flagChanged),GameCore.pokeList[0].flagChanged)

            GameCore.pokeList[i].flagChanged.connect(function(type,id,flag){
                //console.debug("qml poke flag changed:",type,id,flag)
                setPokeFlags(id,flag);
            })
            GameCore.pokeList[i].positionChanged.connect(function(i) {
                setPokePosition(i,GameCore.pokeList[i].positionArea,GameCore.pokeList[i].positionValue,GameCore.pokeList[i].positionPlayer);
            });
            pokeArray[i].clicked.connect(GameCore.pokeClicked);
            Functions.setPokeImage(pokeArray[i],GameCore.pokeList[i].value);
        }

        //玩家
        for(i = 0; i < iPlayerMaxCount; i++) {
            playerArray[i] = playerComp.createObject(gameWindow,{"flags": PokeClass.Flag_Null});
            playerArray[i].userData = i;

            GameCore.playerList[i].s_debugMsg.connect(function(str){
                msgBox.appendText(str);
            })

            GameCore.playerList[i].flagChanged.connect(function(type,id,flag){
                //console.debug("qml player flag changed:",type,id,flag)
                setPlayerFlags(id,flag);
            })
            GameCore.playerList[i].s_setTiLi.connect(function(id,blood,maxBlood){
                //console.debug("qml player flag changed:",type,id,flag)
                setPlayerBlood(id,blood,maxBlood);
            })

            GameCore.playerList[i].s_shouPaiShu.connect(function(id, nCount){
                //console.debug("qml player flag changed:",type,id,flag)
                playerArray[id].shouPaiCount = nCount;
            })
            //console.debug(i)
            playerArray[i].clicked.connect(GameCore.playerClicked);
        }
        console.debug("player count:",i)
        /*
        for(i = 0; i < iWuJiangMaxCount; i++) {
            wuJiangArray[i] = wujiangComp.createObject(gameWindow,{"flags": PokeClass.Flag_Null});
            GameCore.wuJiangList[i].flagChanged.connect(function(flag,j){wuJiangArray[i].flags = flag;})
        }

        GameCore.s_FlagMenus2.connect(function(ok,cancel,giveup){
            console.debug("flag menus!!!",typeof(ok),ok,ok == PokeClass.Flag_Enable)
            ok == PokeClass.Flag_Enable ? buttonOK.enabled = true : buttonOK.enabled = false;
            cancel == PokeClass.Flag_Enable ? buttonCancel.enabled = true : buttonCancel.enabled = false;
            giveup == PokeClass.Flag_Enable ? buttonGiveup.enabled = true : buttonGiveup.enabled = false;
        });

        GameCore.s_FlagMenus1.connect(function(ok,cancel,giveup){
            var test
            test = PokeClass.Flag_Enable

            console.debug("flag menus!!!",typeof(ok),ok,ok == PokeClass.Flag_Enable)
            console.debug("flag menus!!!",typeof(test),test,test == PokeClass.Flag_Enable)
            ok == PokeClass.Flag_Enable ? buttonOK.enabled = true : buttonOK.enabled = false;
            cancel == PokeClass.Flag_Enable ? buttonCancel.enabled = true : buttonCancel.enabled = false;
            giveup == PokeClass.Flag_Enable ? buttonGiveup.enabled = true : buttonGiveup.enabled = false;
        });*/
        /**/
        //3个按钮
        GameCore.s_FlagMenus.connect(function(ok,cancel,giveup){
            (ok == PokeClass.Flag_Enable) ? buttonOK.enabled = true : buttonOK.enabled = false;
            (cancel == PokeClass.Flag_Enable) ? buttonCancel.enabled = true : buttonCancel.enabled = false;
            (giveup == PokeClass.Flag_Enable) ? buttonGiveup.enabled = true : buttonGiveup.enabled = false;

            //buttonOK.enabled = ok;
            //buttonCancel.enabled = cancel;
            //buttonGiveup.enabled = giveup;
        });

        //Game信号
        GameCore.s_DiaoXie.connect(function(i,b){playerArray[i].setBlood(b);})
        GameCore.s_SetPlayerDead.connect(function(w){playerArray[w].bDead = true;})
        GameCore.s_GameInit.connect(function(count,id){init(count,id);})
        GameCore.s_ShowMessage.connect(function(str){msgBox.appendText(str);})
        GameCore.s_ShortShowMessage.connect(function(str){shortMsg.text = str;})
        GameCore.s_ShowDebug.connect(function(str){debugMsg.appendText(str);})
        GameCore.s_StartChuPai.connect(function(player){progress.visible = true; progress.start(GlobalConst.ChuPai_Time,false);})
        GameCore.s_StopChuPai.connect(function(player){progress.stop(); progress.visible = false;})
        GameCore.s_ChuPaiOver.connect(function(list){
            canvas.lineList = list;
            canvas.visible = true;
            canvas.requestPaint();
            canvasHideTimer.start();
        });
        GameCore.s_Wenti.connect(function(obj,answer){
           questionBox.showQuestion(obj,answer)
        });

        //QML信号
        questionBox.choiced.connect(GameCore.questionAnswerd)
        buttonClicked.connect(GameCore.buttonClicked)
        //GameCore..connect(function(){})
    }

    //游戏前初始化
    function init(iPlayerCount,iMyID) {
        visible = true;
        console.debug("init Called")
        myID = iMyID
        playerCount = iPlayerCount
        Functions.setPlayerPos(playerCount)

        var i;
        for(i = 0;i < iPlayerCount; i++) {
            playerArray[i].source = "Player/erzhang.png";
            playerArray[i].flags = PokeClass.Flag_Null
            playerArray[i].visible = true;
            playerArray[i].bDead = false
            //setPlayerBlood(i,i,5);
            playerArray[i].z = 100
        }
        //初始化头像图片,牌图片
        for(; i < playerMaxCount; i++) {
            playerArray[i].visible = false;
        }
        for(i = 0; i < pokeMaxCount; i++) {
            //pokeArray[i].flags = PokeClass.Flag_Enable
            pokeArray[i].bIsMine = false
            pokeArray[i].visible = true;
            pokeArray[i].opacity = 0;
            pokeArray[i].flags = PokeClass.Flag_Null
            pokeArray[i].z = 100
        }

        _audio.play();
    }


    onHeightChanged: {
        //if(width <= height * 1024 / 768)
            width = height * 1024 / 768;
    }
    onWidthChanged: {
        //if(height < width * 768 / 1024)
            height = width * 768 / 1024;
    }


    onClosing: {
        console.debug("exit")
        //close.accepted = false

    }

    Component.onCompleted: {
        //gameWindow.showFullScreen()
        //gameWindow.maximumWidth = GlobalConst.GAMEWINDOW_WIDTH
        //gameWindow.maximumHeight = GlobalConst.GAMEWINDOW_HEIGHT
        //gameWindow.minimumWidth = GlobalConst.GAMEWINDOW_WIDTH
        //gameWindow.minimumHeight = GlobalConst.GAMEWINDOW_HEIGHT
        if(GlobalConst.GAMEWINDOW_FULLSCREEN)gameWindow.showFullScreen();
        else gameWindow.showMaximized();

        //msgBox.appendText("深林孤鹰出<font size=20 color=red>杀</font><br>")
        //msgBox.appendText("资治通鉴出<font size=20 color=blue>闪</font><br>")
        //GameCore.temp_Init(5,0)









        //console.debug("type:",(GameClass._GameButtonValue))
        //console.debug("type:",(GameClass.Game_Button_Giveup))
        //console.debug("type:",(PokeClass._Flags))
        //console.debug("type:",(PokeClass.Flag_Enable))

        /*
        var v1,v2

        v1 = pokeComp.createObject(gameWindow,{"flags": PokeClass.Flag_Null});
        v2 = playerComp.createObject(gameWindow,{"flags": PokeClass.Flag_Null});

        v1.pokeSource = "Pai101.jpg";
        v1.flags = PokeClass.Flag_Show | PokeClass.Flag_Enable | PokeClass.Flag_ZhengMian
        //v1.visible = true;
        v1.x = 0
        v1.y = 0
        //v1.z = 100

        v2.source = "Player/erzhang.png";
        //playerArray[i].flags = PokeClass.Flag_Null;
        v2.visible = true;
        v2.x = 100
        v2.y = 0
        */
        //v2.z = 100
    }

    /*
function test()
{
console.debug("test qml")
}
    Poke {
    //z:100
        pokeSource : "Pai101.jpg"
        pokeBackSource : "PaiBei.jpg"
        flags : PokeClass.Flag_Show | PokeClass.Flag_Enable | PokeClass.Flag_ZhengMian
    }*/
}
